/*
 * Copyright (c) 2010 Zauber S.A.  -- All rights reserved
 */
package ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.bitwise;

import java.util.List;

import org.apache.commons.lang.Validate;

import ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.Expresion;
import ar.edu.itba.ia2010.geneticos.motor.api.sintaxistree.impl.AbstractExpresion;

/**
 * Operador not.
 * 
 * @author Juan F. Codagnone
 * @since Mar 27, 2010
 */
public class Not extends AbstractUnaryExpresion {
    /** caracter representativo */
    static final char CHAR = '!';

    /** Creates the Not. */
    public Not(final Expresion expresion) {
        Validate.notNull(expresion);
        
        childs.add(expresion);
    }

    /** @see Expresion#eval(boolean[]) */
    public final boolean eval(final boolean... vars) {
        assert vars.length == 1;
        
        return !vars[0];
    }
    
    /** @see Expresion#getCharacter() */
    public final char getCharacter() {
        return CHAR;
    }

    /** @see AbstractExpresion#clone(java.util.List) */
    @Override
    protected final Expresion clone(final List<Expresion> clones) {
        return new Not(clones.get(0));
    }
}
